home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / XCMD libraries 960603 / xcmdBase.h < prev    next >
Text File  |  1996-01-24  |  3KB  |  77 lines

  1. //    © Paul B. Beeken, Work In Progress, 1994-5
  2. //    Knowledge Software Consulting.
  3. //
  4. //    These files are a mindlessly simple wrapper class for the
  5. //    basic XCMD operations.  Only one instance of the xcmdBase class is
  6. //    generated per XCMD call but there may be many instances of the XCMDString
  7. //    class.  I have used these classes to whip out XCMD/XFCNs within hours of
  8. //    receiving the specs.  They work great for me but I will always consider 
  9. //    suggestions.
  10. //
  11. //    Please, please, please, in the unlikely event you should use this stuff
  12. //    for some commercial application I would appreciate you contacting me.  If
  13. //    its for your own use, use away. Send email: knowsoft@ios.com
  14. //
  15. //    As always: this file is presented as is with no warrantees expressed or implied.
  16. //    Swim at your own risk, etc. etc.
  17.  
  18. #pragma once
  19.  
  20. #include    "xcmdStrings.h"
  21.  
  22. #ifndef    __HYPERXCMD__
  23. #include    <HyperXCmd.h>
  24. #endif
  25.  
  26. #define    INVALID_INDEX    16
  27. //
  28. //    This is the base class for all xcmds and  xfcns.
  29. //        Only one of these objects is instantiated in the xcmd or xfcn code
  30. //        resource.  It will setup xcmdString's static objects which handles
  31. //        the critical and very ambiguous strings required in these code resources.
  32. //
  33. class    xcmdBase    {
  34.  
  35.     friend    class    xcmdString;            // has to be our friend for us to set it up
  36.  
  37.     private:
  38.         XCmdPtr        paramPtr;            // held static for other methods
  39.         Boolean        paramsLocked;
  40.  
  41.     protected:
  42.         void    passMsg( Boolean p )    { paramPtr->passFlag = p; }
  43.         XCmdPtr    theParamPtr( void )        { return paramPtr; }
  44.         void    lockParams( void );
  45.         void    unlockParams( void );
  46.  
  47.     public:
  48.         xcmdBase( XCmdPtr xP, Boolean lockParams=false );
  49.         ~xcmdBase( void );
  50.  
  51.         /****  HyperTalk Utilities  ****/
  52.         short        evalExpr( xcmdString expr, xcmdString* rc );    // expression evaluation
  53.         short        sendCardMessage( xcmdString msg );        // curr. card a message
  54.         short        sendHCMessage( xcmdString msg );        // hypercard a message
  55.         void        runScript( xcmdString handler );        // run an explicit script
  56.  
  57.         /****  Memory Utilities  ****/
  58.         void        GetGlobal( xcmdString globName, xcmdString* globValue );
  59.         void        SetGlobal( xcmdString globName, xcmdString& globValue );
  60.         void        zeroBytes( Ptr dstPtr, long longCount );
  61.         
  62.         /****  Set returnValue  ****/
  63.         void    errorMsg( xcmdString message );
  64.         void    returnMsg( xcmdString message );
  65.         void    returnNil( void )        { paramPtr->returnValue = nil; }
  66.  
  67.         /****  Parameter checks and utilities ****/
  68.         short    nParams( void )            { return paramPtr->paramCount; }
  69.         Boolean    checkParameters( int min, int max=0 );
  70.         short    scanParams( xcmdString str, short from=0 );    // scan all the parameters for key.
  71.         Handle    operator[]( const int i );
  72.         
  73.     };
  74.  
  75.  
  76.  
  77.